package com.wanglibao.woodtrade.woodtrade.model.impl;

import android.content.Context;

import com.wanglibao.woodtrade.woodtrade.model.WoodTypeDetail;
import com.wanglibao.woodtrade.woodtrade.model.db.BaseDao;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by lugg on 2016/5/10.
 */
public class WoodTypeDetailImpl extends BaseDao<WoodTypeDetail,String> {
    public WoodTypeDetailImpl(Context context) {
        super(context, WoodTypeDetail.class);
    }

    public List<WoodTypeDetail> getWoodTypeDetailByWoodTypeId(String id){
        try {
            return dao.queryForEq("parent_id",id);
        } catch (SQLException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static String[] getStringArray(List<WoodTypeDetail> woodTypeDetails) {
        String[] strings = new String[woodTypeDetails.size()];
        for (int i = 0; i < strings.length; i++) {
            if (woodTypeDetails.get(i) == null) {
                strings[i] = "";
            } else {
                strings[i] = woodTypeDetails.get(i).name.toString();
            }
        }
        return strings;
    }
}
